package com.jic.market.common.enums;

import java.util.EnumSet;

/**
 * @author xuyongliang
 * @version V1.0
 * @className PromotionStatusEnum
 * @description TODO
 * @date 2020/3/5
 */
public enum PromotionStatusEnum {

    // 活动状态 1 待提交  2 待审核  3未开始 4 审核不通过  5 进行中  6 已过期  7 已关闭
    TO_SUBMIT(1, "待提交"),
    TO_AUDIT(2, "待审核"),
    NOT_START(3, "未开始"),
    AUDIT_NOT_PASS(4, "审核不通过"),
    ING(5, "进行中"),
    EXPIRED(6, "已过期"),
    CLOSED(7, "已关闭"),
    END(8, "已结束"),
    DRAFT(9, "草稿"),

    TEMPLATE(10, "模板状态"),
    ;

    private Integer code;

    private String value;

    PromotionStatusEnum(Integer code, String value) {
        this.code = code;
        this.value = value;
    }

    public static PromotionStatusEnum getEnumByCode(Integer code){
        EnumSet<PromotionStatusEnum> elements = EnumSet.allOf(PromotionStatusEnum.class);
        for(PromotionStatusEnum enumType : elements){
            if(enumType.getCode().equals(code)){
                return enumType;
            }
        }
        return null;
    }

    public static int getCodeByValue(String value) {
        for (PromotionStatusEnum c : PromotionStatusEnum.values()) {
            if (c.getValue().equals(value.trim())) {
                return c.code;
            }
        }
        return 0;
    }

    public static String getValue(Integer code) {
        return getEnumByCode(code).getValue();
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }
}
